const baseUrl = "http://localhost:8081/"

function setSession(key , data){

    if(typeof(data) == "object"){
        data = JSON.stringify(data)
    }

    sessionStorage.setItem(key, data)
}

function getSession(key){
    let data = sessionStorage.getItem(key)

    try{ //尝试将数据转换为json
        return JSON.parse(data)
    }
    catch{
        return data
    }

}

function removeSession(key){
    sessionStorage.removeItem(key)
}

function getURIParameter(data){
    let paramters = data.split("&")

    let result = {}
    for(let i = 0; i < paramters.length; i++){
        let arr = paramters[i].split("=")

        result[arr[0]] = arr[1]
    }

    return result
}

function hasLogin(){
        
    let user = getSession('user')

    if(user)
        return user
    
    return null
}